package com.itheima.dao;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class SingletonTemplate {
    private static JdbcTemplate jdbcTemplate=null;
    public static JdbcTemplate getJdbcTemplate(){
        if (jdbcTemplate==null){
            DruidDataSource dataSource=new DruidDataSource();
            dataSource.setDriverClassName("com.mysql.jdbc.Driver");
            dataSource.setUrl("jdbc:mysql://localhost:3306/test");
            dataSource.setUsername("root");
            dataSource.setPassword("root");
            jdbcTemplate = new JdbcTemplate(dataSource);

        }
        return jdbcTemplate;
    }
}
